package com.dementors.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import com.dementors.R;

/**
 * Created by Administrator on 2015/12/5 0005.
 */
public class MyTitleView extends FrameLayout implements View.OnClickListener {
    private Context context;
    private LinearLayout llout;
    private Button btn;
    public OnTitlecheckedListener listener;


    public interface OnTitlecheckedListener{
        void setOnTitleBackListener();
        void setOnTitleToListener();
    }
    public void setOnTitlecheckedListener(OnTitlecheckedListener listener){
        this.listener=listener;
    }
    public void setOnTitleToListener(OnTitlecheckedListener listener){
        this.listener=listener;
    }
    public MyTitleView(Context context) {
        this(context,null);
    }

    public MyTitleView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public MyTitleView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context=context;
        LayoutInflater.from(context).inflate(R.layout.titleview,this,true);
        initViews();//初始化控件
        resigenerListener();//设置监听
    }

    private void resigenerListener() {
        llout.setOnClickListener(this);
        btn.setOnClickListener(this);
    }

    private void initViews() {
        llout= (LinearLayout) findViewById(R.id.llout_login);
        btn= (Button) findViewById(R.id.btn_login);
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.llout_login:
                if (listener!=null){
                    listener.setOnTitleBackListener();
                }
                break;
            case R.id.btn_login:
                if (listener!=null){
                    listener.setOnTitleToListener();
                }
                break;
        }


    }
}
